package com.yanzhengwu.boot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yanzhengwu.boot.core.common.annotation.DataSource;
import com.yanzhengwu.boot.core.common.enums.DataSourcesType;
import com.yanzhengwu.boot.entity.Source;
import org.apache.ibatis.annotations.Insert;

import java.util.List;

/**
 * @Auther: yanzhengwu
 * @Date: 2020/6/8 10:48
 * @Description:
 */
public interface SourceMapper extends BaseMapper<Source> {

    @DataSource(slaveNode = DataSourcesType.SLAVE)
    List<Source> list();

    @DataSource(slaveNode = DataSourcesType.SLAVE)
    @Insert("INSERT INTO  test_slave (id,`name`, `create_Time`) VALUES (#{id},#{name},#{createTime});")
    Integer insertDataSlave(Source source);

    @DataSource(slaveNode = DataSourcesType.MASTER)
    @Insert("INSERT INTO  test_master (id,`name`, `create_Time`) VALUES (#{id},#{name},#{createTime});")
    Integer insertDataMaster(Source source);

    @DataSource(otherSlaveNode = "other")
    @Insert("INSERT INTO  test_other (id,`name`, `create_Time`) VALUES (#{id},#{name},#{createTime});")
    Integer insertDataOther(Source source);

}